﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using T.FAS.Runtime.Metadata.Entity;

namespace T.FAS.Runtime.Action.Plugin
{
    [Serializable]
    public class ActionRefSchemaEntity : IRefSchemaEntity
    {
        public string ID { get; set; }
        public string Code { get; set; }
        public string Name { get; set; }
        public Dictionary<string, Param> Params { get; set; }

        [Serializable]
        public class Param
        {
            public string Code { get; set; }
            public string Text { get; set; }
            public string DataType { get; set; }
            public string ParamType { get; set; }
            public string DefaultValue { get; set; }

            public static Param Mapping(ActionMetaData act, ActionMetaDataMethodParam par)
            {
                if (act == null || par == null) return default;
                var param = new Param
                {
                    Code = par.Code,
                    Text = par.Name,
                    DataType = par.SysDataType.ToString(),
                    ParamType = par.ParamType.ToString(),
                    DefaultValue = par.DefaultValue,
                };
                return param;
            }
        }
    }
}
